<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Franchise_tearm_model extends CI_Model {

    public function loadFranchiseTearm($data = array(), $sort = array('order' => 'ASC')) {
        $this->db->select("*");
        $this->db->from("franchise_team");

        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->db->where($key, $value);
            }
        }

        if (!empty($sort)) {
            foreach ($sort as $key => $value) {
                $this->db->order_by($key, $value);
            }
        }

        if (!empty($group_by)) {
            $this->db->group_by($group_by);
        }



        $query = $this->db->get();

        return $query->result();
    }
    
    public function loadTearmsByFrachiseId($id){
        return $this->loadFranchiseTearm(array('franchise_id' => $id));;
    }

    public function getFrachiseTearmById($id) {
        $result = $this->loadFranchiseTearm(array('id' => $id));
        if (!empty($result))
            return $result[0];
        return FALSE;
    }

}